package pool.dbpool;

import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.SQLException ;

/**
 * 数据库连接对象
 * @author 80002165 @date 2017年7月14日 下午6:42:43
 */
public class DBConnectionUtil {
    private String user  ;
    private String password ;
    private String driverName ;
    private String url ;
    
    
    public static Connection getConnection(String driverName, String url, String user, String password){
        Connection connection = null ;
        try {
            Class.forName(driverName) ;
        } catch (ClassNotFoundException e) {
            System.out.println("加载数据库驱动失败！") ;
            e.printStackTrace();
        }
        
        try {
            connection = DriverManager.getConnection(url,user,password) ;
        } catch (SQLException e) {
            System.out.println("创建数据库连接失败！") ;
            connection = null ;
            e.printStackTrace();
        }
        return connection ;
    }
    
    
}
